package com.bjpowernode.javase.annotation5;

public class ReflectAnnotationTest {
    public static void main(String[] args)throws Exception {
        //获取类
        Class c = Class.forName("com.bjpowernode.javase.annotation5.MyAnnotationTest");
        //判断类上面是否有注解@MyAnnotation()
        System.out.println(c.isAnnotationPresent(MyAnnotation.class));

        if(c.isAnnotationPresent(MyAnnotation.class)){
            MyAnnotation myAnnotation = (MyAnnotation)c.getAnnotation
                    (MyAnnotation.class);
            System.out.println("类上的注解对象"+myAnnotation);
            //获取对象的属性？跟调用接口没区别
            String value = myAnnotation.value();
            System.out.println(value);

        }
        /*//判断字符串上有没有这个注解@MyAnnotation()
        Class stringClass = Class.forName("java.lang.String");
        System.out.println(stringClass.isAnnotationPresent(MyAnnotation.class));*/
    }
}
